import { createApp } from "vue";
import router from "./router";
import store from "./store";
import i18n from "./locales";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import "./assets/scss/style.scss";
import vuetyped from "vue3typed";

import "./assets/scss/index.scss";
// import "default-passive-events";
import App from "./App.vue";
import V3waterfall from "v3-waterfall";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import noData from "@/components/noData.vue";
import track from "@/utils/track.js";
// import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
// import enUs from 'element-plus/dist/locale/en.mjs';
import { VueMasonryPlugin } from "vue-masonry";
import infiniteScroll from "@/utils/scroll.js";
import WebSocketTool from "@/utils/websocket";
const app = createApp(App);
import svgIcon from "./components/SvgIcon.vue";
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
import "nprogress/nprogress.css";

if (store.state.minToken) {
  const webSocketInstance = new WebSocketTool("wss://sns.desai.art/wss");
  let datas = {};
  datas.device = "mp";
  datas.mode = "bind";
  datas.played = "";
  datas.token = store.state.minToken;
  webSocketInstance.connect(datas); // 连接
  // setTimeout(() => {
  store.commit("contentSocket", webSocketInstance);
  // }, 2000);
}

app.component("noData", noData);
app.component("svg-icon", svgIcon);
app.directive("infinite-scroll", infiniteScroll);
app.directive("track", track);
app.use(router);
app.use(store);
app.use(i18n);
app.use(ElementPlus);
app.use(V3waterfall);
app.use(VueMasonryPlugin);
app.use(vuetyped);

// app.use(ElementPlus,{
//     // i18n:(key,value)=>i18n.t(key,value)
//     locale: store.state.lan=='zh'?zhCn:enUs,
// });
app.mount("#app");
